package main

import (
    "fmt"
    "math"
)
//测试数据源
var data_source = []float64{1, 2, 3, 4, 5, 6, 3, 2, 1, 3, 1, 5, 7, 8, 9, 10, 8, 7, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}

func main() {
    //数学期望
    var sum float64 = 0
    for _, v := range data_source {
        sum += v
    }
    μ := float64(sum) / float64(len(data_source))

    //标准差
    var variance float64
    for _, v := range data_source {
        variance += math.Pow((v - μ), 2)
    }
    σ := math.Sqrt(variance / float64(len(data_source)))
    fmt.Println("σ:", σ)
    fmt.Println("μ:", μ)

    //正态分布公式
    a := 1 / (math.Sqrt(2*math.Pi) * σ) * math.Pow(math.E, (-math.Pow((μ-μ), 2)/(2*math.Pow(σ, 2))))
    fmt.Println(a)
}